SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00001 1 05-25-9408:24ALL ALEX KARIPIDIS Listing TSR's SWAG9405 26 /Å {πWell, here it is, a program that lists TSRs loaded.πAnybody willing to enhance it so that it checks the HMA for TSRs too?ππOh, were do I send this so that it gets into the next SWAGS release? I wasπunable to find such a program in the all the SWAGS until (and inclusive) theπlatest February '94 release...ππ{ ------------ Cut Here ----------- }ππProgram ListTSRs;ππ{π Written by Alex Karipidis on the 8th of March 1994.π Donated to the public domain. Use this code freely.ππ You can contact me at:π Fidonet : 2:410/204.4π Hellasnet: 7:2000/50.4π SBCnet : 14:2100/201.4π Zyxelnet : 16:800/108.4π Pascalnet: 115:3005/1.4ππ If you enhance/improve this code in any way, I would appreciate it if youπ sent me a copy of your version.ππ I will not be responsible for any damage caused by this code.ππ This program will print a list of all programs currently loaded inπ memory.π}ππTypeππ pMCB_Rec = ^MCB_Rec;π MCB_Rec = Recordπ ChainID : Byte; { 77 if part of MCB chain, 90 if last MCB allocated }π Owner : Word; { PSP segment address of the MCB's owner }π Paragraphs : Word; { Paragraphs related to this MCB }π end;ππVarπ MCB : pMCB_Rec;π InVarsSeg, InVarsOfs : Word;π EnvSeg, Counter : Word;ππbeginπ { Dos service 52h returns the address of the DOS "invars" table in ES:BX }π { !!! This is an undocumented DOS function !!! }π asmπ MOV AH,52hπ INT 21hπ MOV InVarsSeg,ESπ MOV InVarsOfs,BXπ end;ππ {π The word before the "invars" table is the segment of the first MCBπ allocated by DOS.π }π MCB := Ptr (MemW [InVarsSeg:InVarsOfs-2], 0);ππ While MCB^.ChainID <> 90 do { While valid MCBs exist... }π beginππ If MCB^.Owner = Seg (MCB^) + 1 then { If MCB owns itself, then... }π beginπ Write ('In memory: '); { We've found a program in memory }ππ {π The word at offset 2Ch of the program's PSP contains the value ofπ the program's environment data area. That's were the program's nameπ is located.π }π EnvSeg := MemW [MCB^.Owner:$2C];ππ {π The environment also contains the environment variables as ASCIIZπ (null-terminated) strings. Two consecutive null (0) bytes mean thatπ the environment variables have ended and the program name followsπ after 4 bytes. That is also an ASCIIZ string.π }π Counter := 0;π While (Mem [EnvSeg:Counter ] <> 0) or { Find 2 consecutive }π (Mem [EnvSeg:Counter+1] <> 0) do { null bytes. }π inc (counter);ππ inc (counter,4); { Program name follows after 4 bytes }ππ While Mem [EnvSeg:Counter] <> 0 do { Print program name }π beginπ Write (Char (Mem [EnvSeg : Counter]));π Inc (counter);π end;ππ WriteLn;ππ end;ππ { Point to next MCB }π MCB := Ptr (Seg (MCB^) + MCB^.Paragraphs + 1, 0);π end;ππ {π Note: The last MCB is not processed!π It is assumed that it is this program's MCB.π In your programs, this may or may not be the case.π }ππend.π